package org.oyrm.kobo.formBuilder.controller;

import org.oyrm.kobo.formBuilder.ui.CenterPanel;
import org.oyrm.kobo.formBuilder.ui.DesktopFormBuilderFrame;
import org.oyrm.kobo.formBuilder.ui.LeftPanel;
import org.oyrm.kobo.formBuilder.ui.MainMenuBar;
import org.oyrm.kobo.postproc.ui.PreferencesDialog;



public class FormBuilderController implements IFormBuilderListener{

	/**
	 * Tree view for a view of all the parts of the form in question
	 */
	private LeftPanel leftPanel = null;
	
	/**
	 * The panel that holds the center
	 */
	private CenterPanel centerPanel = null;
	
	/**
	 * The frame frome which all form building action comes forth
	 */
	private DesktopFormBuilderFrame mainFrame = null;
	
	
	public void setMenuBar(MainMenuBar menuBar) {
		this.menuBar = menuBar;
	}

	private MainMenuBar menuBar = null;
	
	/**
	 * Constructor
	 * @param leftPanel
	 * @param centerPanel
	 * @param mainFrame
	 */
	
	public FormBuilderController(LeftPanel leftPanel, CenterPanel centerPanel, DesktopFormBuilderFrame mainFrame)
	{
		this.leftPanel = leftPanel;
		this.centerPanel = centerPanel;
		this.mainFrame = mainFrame;
	}
	
	@Override
	public void postProcess() {
		if(menuBar != null)
		{
			menuBar.showPostProcOptions(true);
		}
		centerPanel.showPostProcessor();
	}

	@Override
	public void postProcessOptions() {
		new PreferencesDialog(mainFrame);
		
	}



}
